package com.ydjk.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ydjk.common.annotation.Log;
import com.ydjk.common.core.controller.BaseController;
import com.ydjk.common.core.domain.AjaxResult;
import com.ydjk.common.enums.BusinessType;
import com.ydjk.domain.JkVideo;
import com.ydjk.service.IJkVideoService;
import com.ydjk.common.utils.poi.ExcelUtil;
import com.ydjk.common.core.page.TableDataInfo;

/**
 * 康复锻炼视频管理Controller
 *
 * @author ydjk
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/recover/video")
public class JkVideoController extends BaseController
{
    @Autowired
    private IJkVideoService jkVideoService;

    /**
     * 查询康复锻炼视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('recover:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(JkVideo jkVideo)
    {
        startPage();
        List<JkVideo> list = jkVideoService.selectJkVideoList(jkVideo);
        return getDataTable(list);
    }

    /**
     * 导出康复锻炼视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('recover:video:export')")
    @Log(title = "康复锻炼视频管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JkVideo jkVideo)
    {
        List<JkVideo> list = jkVideoService.selectJkVideoList(jkVideo);
        ExcelUtil<JkVideo> util = new ExcelUtil<JkVideo>(JkVideo.class);
        util.exportExcel(response, list, "康复锻炼视频管理数据");
    }

    /**
     * 获取康复锻炼视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('recover:video:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jkVideoService.selectJkVideoById(id));
    }

    /**
     * 新增康复锻炼视频管理
     */
    @PreAuthorize("@ss.hasPermi('recover:video:add')")
    @Log(title = "康复锻炼视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JkVideo jkVideo)
    {
        return toAjax(jkVideoService.insertJkVideo(jkVideo));
    }

    /**
     * 修改康复锻炼视频管理
     */
    @PreAuthorize("@ss.hasPermi('recover:video:edit')")
    @Log(title = "康复锻炼视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JkVideo jkVideo)
    {
        return toAjax(jkVideoService.updateJkVideo(jkVideo));
    }

    /**
     * 删除康复锻炼视频管理
     */
    @PreAuthorize("@ss.hasPermi('recover:video:remove')")
    @Log(title = "康复锻炼视频管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jkVideoService.deleteJkVideoByIds(ids));
    }
}
